//
//  HydroRepairCell.m
//  PropertyMananger
//
//  Created by bh on 17/1/23.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "HydroRepairCell.h"

@implementation HydroRepairCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"HydroRepairCellID";
    HydroRepairCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[HydroRepairCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    //选中cell的颜色 -无色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.orderCodeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.orderCodeLabel];
        
        self.orderCodeLabel.textColor = BHColor(51, 51, 51);
        self.orderCodeLabel.textAlignment = NSTextAlignmentLeft;
        self.orderCodeLabel.font = BHFont(15);
        self.orderCodeLabel.text = @"订单编号：2323434343433";
      //  self.orderCodeLabel.backgroundColor = BHRandColor;
        
        [self.orderCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(self).with.offset(12.5);
            make.height.mas_equalTo(25);
        }];
        
//        self.iconImg = [[UIImageView alloc]init];
//        [self.contentView addSubview:self.iconImg];
//        self.iconImg.image = IMG(@"ico_new");
//        
//        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.leading.equalTo(self.orderCodeLabel.mas_trailing).with.offset(5);
//            make.top.equalTo(self.orderCodeLabel).with.offset(5);
//            make.size.mas_equalTo(CGSizeMake(15, 15));
//        }];
        
        self.orderProgressLable = [[UILabel alloc]init];
        [self.contentView addSubview:self.orderProgressLable];
        
        [self.orderProgressLable mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(self.orderCodeLabel.mas_trailing).with.offset(10);
            make.centerY.equalTo(self.orderCodeLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(40, 25));
        }];
        
        self.orderProgressLable.textAlignment = NSTextAlignmentCenter;
        self.orderProgressLable.font = BHFont(10);
        self.orderProgressLable.text  = @"待处理";
        
        self.orderProgressLable.layer.cornerRadius = 3;
        self.orderProgressLable.layer.masksToBounds = YES;
        self.orderProgressLable.layer.borderWidth = 0.5;
        
        
        UIImageView * arrowImg = [[UIImageView alloc]init];
        [self.contentView addSubview:arrowImg];
        arrowImg.image = IMG(@"ico_work_order_next");
        
        [arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.trailing.equalTo(self).with.offset(-15);
            make.centerY.equalTo(self.orderProgressLable).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(8, 14));
        }];
        
        UIView * lineView = [[UIView alloc]init];
        [self.contentView addSubview:lineView];
        
        lineView.backgroundColor = BHColor(230, 230, 230);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 1));
            make.top.equalTo(self.orderCodeLabel.mas_bottom).with.offset(12.5);
        }];
        //报修类型
        UIImageView * complianManIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:complianManIcon];
        complianManIcon.image = IMG(@"ico_repair_type");
        
        [complianManIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(lineView).with.offset(15);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * complianManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:complianManLabel];
        
        complianManLabel.textColor = BHColor(102, 102, 102);
        complianManLabel.textAlignment = NSTextAlignmentLeft;
        complianManLabel.font = BHFont(15);
        complianManLabel.text  = @"报修类型:";
        
        [complianManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianManIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(complianManIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.repiarTypeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repiarTypeLabel];
        
        self.repiarTypeLabel.textColor = BHColor(51, 51, 51);
        self.repiarTypeLabel.textAlignment = NSTextAlignmentLeft;
        self.repiarTypeLabel.font = BHFont(15);
        self.repiarTypeLabel.text  = @"垃圾桶损坏";
        // self.complianManLabel.backgroundColor = BHRandColor;
        
        [self.repiarTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(complianManLabel.mas_trailing).with.offset(0);
            make.top.equalTo(complianManLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/3, 25));
        }];
        
        //投诉地点
        UIImageView * repiarAdressIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:repiarAdressIcon];
        repiarAdressIcon.image = IMG(@"ico_repair_place");
        
        [repiarAdressIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(complianManIcon.mas_bottom).with.offset(30);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * repiarAdressLabel = [[UILabel alloc]init];
        [self.contentView addSubview:repiarAdressLabel];
        
        repiarAdressLabel.textColor = BHColor(102, 102, 102);
        repiarAdressLabel.textAlignment = NSTextAlignmentLeft;
        repiarAdressLabel.font = BHFont(15);
        repiarAdressLabel.text  = @"地点:";
        
        [repiarAdressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(repiarAdressIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(repiarAdressIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(40, 25));
        }];
        
        self.repiarAdressLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repiarAdressLabel];
        
        self.repiarAdressLabel.textColor = BHColor(51, 51, 51);
        self.repiarAdressLabel.textAlignment = NSTextAlignmentLeft;
        self.repiarAdressLabel.font = BHFont(15);
        self.repiarAdressLabel.text  = @"中智鸿博";
        //   self.timeLabel.backgroundColor = BHRandColor;
        
        [self.repiarAdressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(repiarAdressLabel.mas_trailing).with.offset(0);
            make.top.equalTo(repiarAdressLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW/2+50, 25));
        }];
        
        //报修人
        UIImageView * repiarManIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:repiarManIcon];
        repiarManIcon.image = IMG(@"ico_repair_people");
        
        [repiarManIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(repiarAdressIcon.mas_bottom).with.offset(30);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * repiarManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:repiarManLabel];
        
        repiarManLabel.textColor = BHColor(102, 102, 102);
        repiarManLabel.textAlignment = NSTextAlignmentLeft;
        repiarManLabel.font = BHFont(15);
        repiarManLabel.text  = @"报修人:";
        
        [repiarManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(repiarManIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(repiarManIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(60, 25));
        }];
        
        self.repiarManLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.repiarManLabel];
        
        self.repiarManLabel.textColor = BHColor(51, 51, 51);
        self.repiarManLabel.textAlignment = NSTextAlignmentLeft;
        self.repiarManLabel.font = BHFont(15);
        self.repiarManLabel.numberOfLines = 5;
        self.repiarManLabel.text  = @"吴敏";
        
        [self.repiarManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(repiarManLabel.mas_trailing).with.offset(0);
            make.centerY.equalTo(repiarManLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 100, 50));
        }];
        
        UIImageView * appointTimeIcon = [[UIImageView alloc]init];
        [self.contentView addSubview:appointTimeIcon];
        appointTimeIcon.image = IMG(@"ico_repair_time");
        
        [appointTimeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(repiarManIcon.mas_bottom).with.offset(30);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel * appointTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:appointTimeLabel];
        
        appointTimeLabel.textColor = BHColor(102, 102, 102);
        appointTimeLabel.textAlignment = NSTextAlignmentLeft;
        appointTimeLabel.font = BHFont(15);
        appointTimeLabel.text  = @"预约时间:";
        
        [appointTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(appointTimeIcon.mas_trailing).with.offset(10);
            make.centerY.equalTo(appointTimeIcon).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 25));
        }];
        
        self.appointTimeLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.appointTimeLabel];
        
        self.appointTimeLabel.textColor = BHColor(51, 51, 51);
        self.appointTimeLabel.textAlignment = NSTextAlignmentLeft;
        self.appointTimeLabel.font = BHFont(15);
        self.appointTimeLabel.numberOfLines = 5;
        self.appointTimeLabel.text  = @"吴敏";
        
        [self.appointTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.leading.equalTo(appointTimeLabel.mas_trailing).with.offset(0);
            make.centerY.equalTo(appointTimeLabel).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW - 100, 50));
        }];
        
//        UIView * bottomView = [[UIView alloc]init];
//        [self.contentView addSubview:bottomView];
//        bottomView.backgroundColor = BHColor(230, 230, 230);
//        
//        [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.leading.equalTo(self.contentView).with.offset(15);
//            make.top.equalTo(self.appointTimeLabel.mas_bottom).with.offset(5);
//            make.size.mas_equalTo(CGSizeMake(BHscreenW - 15, 1));
//        }];

        
    }
    return self;
}

- (void)setModel:(PublicRepairModel *)model{
    
    _model = model;
    DLog(@"===%@",model);
    if ([model.ProcessState isEqualToString:@"10"]) {
        
        self.orderProgressLable.text = @"待处理";
        self.orderProgressLable.textColor = [UIColor redColor];
        self.orderProgressLable.layer.borderColor = [UIColor redColor].CGColor;
        
    }else if ([model.ProcessState isEqualToString:@"20"]){
        
        self.orderProgressLable.text = @"已撤销";
        self.orderProgressLable.textColor = BHGrayColor;
        self.orderProgressLable.layer.borderColor = BHGrayColor.CGColor;
        
    }else if ([model.ProcessState isEqualToString:@"30"]){
        
        self.orderProgressLable.text = @"处理中";
        self.orderProgressLable.textColor = BHColor(215, 152, 2);
        self.orderProgressLable.layer.borderColor = BHColor(215, 152, 2).CGColor;
        
    }else if ([model.ProcessState isEqualToString:@"100"]){
        self.orderProgressLable.text = @"已处理";
        self.orderProgressLable.textColor = BHColor(17, 177, 31);
        self.orderProgressLable.layer.borderColor = BHColor(17, 177, 31).CGColor;
    }else if ([model.ProcessState isEqualToString:@"40"]){
        self.orderProgressLable.text = @"已回访";
        self.orderProgressLable.textColor = BHColor(1, 181, 151);
        self.orderProgressLable.layer.borderColor = BHColor(1, 181, 151).CGColor;
    }else if ([model.ProcessState isEqualToString:@"50"]){
        self.orderProgressLable.text = @"完成";
        self.orderProgressLable.textColor = [UIColor redColor];
        self.orderProgressLable.layer.borderColor =[UIColor redColor].CGColor;
    }
    
}

@end
